import { createApp } from 'vue'
import App from './App.vue'

// 引入elementplus
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
//这个是icon的依赖,文档说要单独跟着流程来走
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
//这个是组件的默认文案的依赖（如按钮、弹窗等的提示信息）将会显示为中文
import zhCn from 'element-plus/dist/locale/zh-cn.mjs';

// 引入路由
import router from './router'

// 引入pinia
import { createPinia } from 'pinia'
const pinia = createPinia()

//引入pinia持久化，存储local
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'

// 引入rem
import "@/utils/rem"

// 引入樹形圖組件(vue3-tree-org)
import vue3TreeOrg from 'vue3-tree-org';
import "vue3-tree-org/lib/vue3-tree-org.css";


const app = createApp(App)
app.use(ElementPlus, { locale: zhCn })
app.use(router)
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}
app.use(pinia)
pinia.use(piniaPluginPersistedstate)
app.use(vue3TreeOrg)

app.mount('#app')

// const debounce = (fn, delay) => {
//     let timer
//     return (...args) => {
//         if (timer) {
//             clearTimeout(timer)
//         }
//         timer = setTimeout(() => {
//             fn(...args)
//         }, delay)
//     }
// }
// const _ResizeObserver = window.ResizeObserver;
// window.ResizeObserver = class ResizeObserver extends _ResizeObserver {
//     constructor(callback) {
//         callback = debounce(callback, 200);
//         super(callback);
//     }
// }
